<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 创建对象的第三种方式  前面两个只能创建一个对象  -->
    <!--  
 // 格式
// function 构造函数名()  函数名要首字母要大写
// {
//     this.属性=值;
//     this.方法=Function(){}
// }
// 调用 new 构造函数名() 

-->
    <script>
        //构造函数
        function Star(name, age, sex) {
            this.name = name;
            this.sex = sex;
            this.age = age;
            this.geth = function() {
                console.log(22);
            };

        }
        //对
        var ldh = new Star('刘德华', 18, '男');
        var zxy = new Star('张学友', 17, '男')
        console.log(ldh.name);
        console.log(ldh['name']);
        ldh.geth()
        console.log(zxy.name);
        console.log(zxy['name']);
    </script>
</head>

<body>

</body>

</html>